<?php

$params = require __DIR__ . '/params.php';
if (YII_ENV_PROD) {
    $db = require __DIR__ . '/diff-env-web/prod.php';
    $params = array_merge($params, require __DIR__ . '/diff-env-param/prod.php');
} elseif (YII_ENV_DEV) {
    $db = require __DIR__ . '/diff-env-web/dev.php';
    $params = array_merge($params, require __DIR__ . '/diff-env-param/dev.php');

} elseif (YII_ENV_TEST) {
    $db =  require __DIR__ . '/diff-env-web/test.php';
    $params = array_merge($params, require __DIR__ . '/diff-env-param/test.php');
} elseif (YII_ENV_LOCAL) {
    $db =  require __DIR__ . '/diff-env-web/local.php';
    $params = array_merge($params, require __DIR__ . '/diff-env-param/local.php');
}

$config = [
    'id' => 'basic',
    'name' =>'区块链信息平台GM',
    'basePath' => dirname(__DIR__),
    'defaultRoute' => '/project/index',
    'timeZone' => 'Asia/Shanghai',
    'controllerNamespace' => 'app\controllers',
    'bootstrap' => ['log'],
    // 'language' => 'en-US',
    'sourceLanguage' => 'en-US',
    'version' => '1.0.0',
    'aliases' => [
        '@bower' => '@vendor/bower-asset',
        '@npm'   => '@vendor/npm-asset',
    ],
    'components' => [
        'request' => [
            // !!! insert a secret key in the following (if it is empty) - this is required by cookie validation
            'cookieValidationKey' => 'W29aTJOq6zblfnGkounKh8dPQ3qfK6MA',
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'targets' => [
                [
                    'class' => 'yii\log\FileTarget',
                    'levels' => ['error', 'warning'],
                ],
            ],
        ],
        'db' => $db['db'],
        'redis' => $db['redis'],
        'urlManager'=>[
            'class' => 'yii\web\UrlManager',
            'enablePrettyUrl' => true,
            'showScriptName' => false,
            'rules'=>[
                '<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
            ],
        ],
        // "skin-blue",
        // "skin-black",
        // "skin-red",
        // "skin-yellow",
        // "skin-purple",
        // "skin-green",
        // "skin-blue-light",
        // "skin-black-light",
        // "skin-red-light",
        // "skin-yellow-light",
        // "skin-purple-light",
        // "skin-green-light"
        //更换后台主题
        'assetManager' => [
            'bundles' => [
                'dmstr\web\AdminLteAsset' => [
                    'skin' => "skin-blue",
                ],
            ],
        ],

        'formatter' => [
            'nullDisplay' => '',
            'dateFormat' => 'Y-m-d',
            'datetimeFormat' => 'Y-m-d H:i:s',
            // 'decimalSeparator' => ',',
            // 'thousandSeparator' => ' ',
            // 'currencyCode' => 'CNY',
        ],
    ],
    'params' => $params,
];

if (YII_ENV_DEV || YII_ENV_LOCAL) {
    // configuration adjustments for 'dev' environment
    $config['bootstrap'][] = 'debug';
    $config['modules']['debug'] = [
        'class' => 'yii\debug\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        //'allowedIPs' => ['127.0.0.1', '::1'],
    ];

    $config['bootstrap'][] = 'gii';
    // $config['modules']['gii'] = [
    //     'class' => 'yii\gii\Module',
    //     // uncomment the following to add your IP if you are not connecting from localhost.
    //     //'allowedIPs' => ['127.0.0.1', '::1'],
    // ];
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',      
        'allowedIPs' => ['127.0.0.1', '::1', '192.168.0.*', '192.168.178.20'],  
        'generators' => [ //here
            'crud' => [
                'class' => 'yii\gii\generators\crud\Generator',
                'templates' => [
                    'adminlte' => '@vendor/dmstr/yii2-adminlte-asset/gii/templates/crud/simple',
                ]
            ]
        ],
    ];
}

return $config;
